//
//  RadioTableViewCell.m
//  CarTown
//
//  Created by xionghao on 15/8/10.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "RadioTableViewCell.h"
#import "Radiogroup.h"
#import "Pubmode.h"

@interface RadioTableViewCell ()<RadiobuttonSelectDelegate>

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *width;
@end

@implementation RadioTableViewCell
+(instancetype)cellWithTablView:(UITableView *)tableview{
    
    static NSString *ID=@"radio";
    
    RadioTableViewCell *cell=[tableview dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        [tableview registerNib:[UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil] forCellReuseIdentifier:ID];
        cell=[tableview dequeueReusableCellWithIdentifier:ID];
    }
    return cell;
}
- (void)awakeFromNib {
    // Initialization code
    self.radiogroup.delegate=self;
    if (XHScreenwidth==320) {
        self.width.constant=212;
        
    }else{
        self.width.constant=264;
    }
}
-(void)RadiobuttonSelect:(NSInteger)index withValue:(NSString *)value{
    self.mode.radioindex=index;
    if ([_delegate respondsToSelector:@selector(radioclickwithcell:withIndex:)]) {
        [_delegate radioclickwithcell:self withIndex:index];
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setMode:(Pubmode *)mode{
    _mode=mode;
    self.radiogroup.titlesarray=_mode.titlearray;
    self.name.text=_mode.name;
    self.radiogroup.selectedIndex=_mode.radioindex;
    self.radiogroup.isnotcancel=_mode.isNotCancel;
}
@end
